<template>
  <el-input
    type="textarea"
    @change="searchFun"
    :placeholder="data.placeholder ? data.placeholder : '请输入'"
    :rows="data.rows ? data.rows : 2"
    v-model.trim="formData[data.field]"
    :disabled="data.disabled"
    :maxlength="data.maxLength ? data.maxLength : Infinity"
    :show-word-limit="Boolean(data.maxLength)"
  />
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { baseForm } from '@/common/mixins/index'

export default defineComponent({
  name: 'MultiText',
  props: {
    form: {
      type: Object,
      default: () => ({})
    },
    data: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ['onSearchFun', 'update:form'],
  setup(props, { emit }) {
    const formData = computed({
      get: () => props.form,
      set: (val) => emit('update:form', val)
    })

    const searchFun = () => {
      baseForm.searchFun(emit)
    }
    return { searchFun, formData }
  }
})
</script>

<style lang="stylus" scoped></style>
